import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1636823982176_2136';

  config.middleware = [ 'errorHandler' ];
  // 只对 /api 前缀的 url 路径生效
  config.errorHandler = {
    match: '/api',
  };
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: '127.0.0.1', // Redis host
      password: '',
      db: 0,
    },
  };
  config.jwt = {
    secret: 'zhong',
  };
  config.security = {
    csrf: {
      enable: false,
    },
  };
  config.captchaOption = {
    size: 4, // 长度(显示几个字符)
    fontSize: 36, // 字体大小
    width: 80, // 宽度
    height: 30, // 高度
    background: '#72a1b5', // 背景颜色
    outTime: 60, // 超时时间
  };
  // add your special config in here
  // const bizConfig = {
  //   sourceUrl: `https://github.com/eggjs/examples/tree/master/${ appInfo.name }`,
  // };

  // the return config will combines to EggAppConfig
  return {
    ...config,
  };
};
